﻿using Furion.CMS.Core;
using Furion.CMS.Core.Permission;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Furion.CMS.Application
{
    public class BasePermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            var settingsManager = context.AddGroup<SiteSettingAppService>("网站配置管理");
            settingsManager.AddPermission(m => m.GetSettings, "获取网站配置");
            settingsManager.AddPermission(m => m.UpdateSettings, "更新获取网站配置");

            var blackWhitelistManager = context.AddGroup<BlackWhiteListAppService>("黑白名单管理");
            blackWhitelistManager.AddPermission(m => m.AddBlacklist, "添加黑名单");
            blackWhitelistManager.AddPermission(m => m.RemoveBlacklist, "移除黑名单");

            var userManager = context.AddGroup<UserAppService>("用户管理");
            userManager.AddPermission(m => m.GetDetail, "用户详情");
            userManager.AddPermission(m => m.Create, "创建用户");
            userManager.AddPermission(m => m.Update, "更新用户");
            userManager.AddPermission(m => m.Delete, "删除用户");
            userManager.AddPermission(m => m.UpdataPassword, "修改密码");
            userManager.AddPermission(m => m.GetPermissions, "获取权限");
            userManager.AddPermission(m => m.UpdatePermissions, "更新权限");

            var loginRecord = context.AddGroup<LoginRecordAppService>("登录日志管理");
            loginRecord.AddPermission(m => m.GetDetail, "日志详情");
            loginRecord.AddPermission(m => m.GetRelatedRecords, "关联日志列表");

            var roleManager = context.AddGroup<RoleAppService>("角色管理");
            roleManager.AddPermission(m => m.GetDetail, "角色详情");
            roleManager.AddPermission(m => m.Create, "创建角色");
            roleManager.AddPermission(m => m.Update, "更新角色");
            roleManager.AddPermission(m => m.GetConfigre, "获取权限配置");
            roleManager.AddPermission(m => m.UpdateConfigre, "更新权限配置");
            roleManager.AddPermission(m => m.Delete, "删除角色");
            roleManager.AddPermission(m => m.GetUsers, "获取角色授权");
            roleManager.AddPermission(m => m.UpdateUsers, "更新角色授权");

            var orgManager = context.AddGroup<OrganizationAppService>("组织机构管理");
            orgManager.AddPermission(m => m.GetDetail, "机构详情");
            orgManager.AddPermission(m => m.Create, "创建机构");
            orgManager.AddPermission(m => m.Update, "更新机构");
            orgManager.AddPermission(m => m.Delete, "删除机构");
            orgManager.AddPermission(m => m.UpdateUsers, "分配机构人员");
            orgManager.AddPermission(m => m.DeleteUsers, "删除机构人员");
            orgManager.AddPermission(m => m.UpdateRoles, "分配机构角色");
            orgManager.AddPermission(m => m.DeleteRoles, "删除机构角色");

            var crontabManager = context.AddGroup<Services.CrontabAppService>("定时任务管理");
            crontabManager.AddPermission(m => m.Create, "创建定时任务");
            crontabManager.AddPermission(m => m.Update, "更新定时任务");
            crontabManager.AddPermission(m => m.Delete, "删除定时任务");
            crontabManager.AddPermission(m => m.GetDetail, "定时任务详情");
            crontabManager.AddPermission(m => m.Start, "启动定时任务");
            crontabManager.AddPermission(m => m.Stop, "停止定时任务");

            var dicManager = context.AddGroup<DataDictionaryAppService>("数据字典管理");
            dicManager.AddPermission(m => m.Create, "创建字典");
            dicManager.AddPermission(m => m.GetDetail, "字典详情");
            dicManager.AddPermission(m => m.Update, "更新字典");
            dicManager.AddPermission(m => m.Delete, "删除字典");
            dicManager.AddPermission(m => m.CreateCategory, "创建字典类别");
            dicManager.AddPermission(m => m.GetCategoryDetail, "字典类别详情");
            dicManager.AddPermission(m => m.UpdateCategory, "更新字典类别");
            dicManager.AddPermission(m => m.DeleteCategory, "删除字典类别");
        }
    }
}
